<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>usleep</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_010_298">&nbsp;</a>NAME</h4><blockquote>
usleep - suspend execution for an interval
</blockquote><h4><a name = "tag_000_010_299">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="unistd.h.html">unistd.h</a>&gt;

int usleep(useconds_t <i>useconds</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_010_300">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>usleep()</i>
function will cause the calling thread to be suspended from
execution until either the number of real-time microseconds specified
by the argument
<i>useconds</i>
has elapsed or a signal is delivered to the calling thread 
and its action is to invoke a signal-catching function or to
terminate the process.
The suspension time may be longer than requested due to the
scheduling of other activity by the system.
<p>
The <i>useconds</i> argument must be less than 1,000,000.  If the value of
<i>useconds</i> is 0, then the call has no effect.
<p>
If a SIGALRM signal is generated for the calling process during
execution of
<i>usleep()</i>
and if the SIGALRM signal is being ignored or blocked
from delivery, it is unspecified whether
<i>usleep()</i>
returns when the SIGALRM signal is scheduled.
If the signal is being blocked, it is also unspecified whether it
remains pending after
<i>usleep()</i>
returns or it is discarded.
<p>
If a SIGALRM signal is generated for the calling process during
execution of
<i>usleep()</i>,
except as a result of a prior call to
<i><a href="alarm.html">alarm()</a></i>,
and if the SIGALRM signal is not being ignored or
blocked from delivery, it is unspecified whether that signal has
any effect other than causing
<i>usleep()</i>
to return.
<p>
If a signal-catching function interrupts
<i>usleep()</i>
and examines or changes either the time a SIGALRM is
scheduled to be generated, the action associated with the SIGALRM
signal, or whether the SIGALRM signal is blocked from delivery,
the results are unspecified.
<p>
If a signal-catching function interrupts
<i>usleep()</i>
and calls
<i><a href="siglongjmp.html">siglongjmp()</a></i>
or
<i><a href="longjmp.html">longjmp()</a></i>
to restore an environment saved prior to the
<i>usleep()</i>
call, the action associated with the SIGALRM signal and the time
at which a SIGALRM signal is scheduled to be generated are
unspecified.
It is also unspecified whether the SIGALRM signal is blocked,
unless the process' signal mask is restored as part of the
environment.
<p>
Implementations may place limitations on the granularity of timer values.
For each interval timer, if the requested timer value requires a finer
granularity than the implementation supports, the actual timer value will be
rounded up to the next supported value.
<p>
Interactions between
<i>usleep()</i>
and any of the following are unspecified:
<p>
<i><a href="nanosleep.html">nanosleep()</a></i>
<pre>
<i><a href="setitimer.html">setitimer()</a></i>
<i><a href="timer_create.html">timer_create()</a></i>
<i><a href="timer_delete.html">timer_delete()</a></i>
<i><a href="timer_getoverrun.html">timer_getoverrun()</a></i>
<i><a href="timer_gettime.html">timer_gettime()</a></i>
<i><a href="timer_settime.html">timer_settime()</a></i>
<i><a href="ualarm.html">ualarm()</a></i>
<i><a href="sleep.html">sleep()</a></i>
</pre>
</blockquote><h4><a name = "tag_000_010_301">&nbsp;</a>RETURN VALUE</h4><blockquote>
On successful completion,
<i>usleep()</i>
returns 0.
Otherwise, it returns -1 and sets <i>errno</i> to indicate the error.
</blockquote><h4><a name = "tag_000_010_302">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>usleep()</i>
function may fail if:
<dl compact>

<dt>[EINVAL]<dd>
The time interval specified 1,000,000 or more microseconds.

</dl>
</blockquote><h4><a name = "tag_000_010_303">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_304">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
Applications are recommended to use
<i><a href="setitimer.html">setitimer()</a></i>,
<i><a href="timer_create.html">timer_create()</a></i>,
<i><a href="timer_delete.html">timer_delete()</a></i>,
<i><a href="timer_getoverrun.html">timer_getoverrun()</a></i>,
<i><a href="timer_gettime.html">timer_gettime()</a></i>
or
<i><a href="timer_settime.html">timer_settime()</a></i>
instead of this interface.
</blockquote><h4><a name = "tag_000_010_305">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_306">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="alarm.html">alarm()</a></i>,
<i><a href="getitimer.html">getitimer()</a></i>,
<i><a href="nanosleep.html">nanosleep()</a></i>,
<i><a href="sigaction.html">sigaction()</a></i>,
<i><a href="sleep.html">sleep()</a></i>,
<i><a href="timer_create.html">timer_create()</a></i>,
<i><a href="timer_delete.html">timer_delete()</a></i>,
<i><a href="timer_getoverrun.html">timer_getoverrun()</a></i>,
<i><a href="timer_gettime.html">timer_gettime()</a></i>,
<i><a href="timer_settime.html">timer_settime()</a></i>,
<i><a href="unistd.h.html">&lt;unistd.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
